package com.sl.au.service;

import java.util.List;
import java.util.Map;

import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;

import com.sl.au.entity.EXDEViExdeBeforeContractWithSign;
import com.sl.au.entity.ExdeBeforeContract;
import com.sl.au.entity.ExdeBeforeContractCounterSign;
import com.sl.au.entity.ExdeBeforeContractDetailParts;
import com.sl.au.entity.ExdeBeforeContractDetails;
import com.sl.au.entity.ExdeBeforeContractNotices;
import com.sl.au.entity.ExdeBeforeContractSpecialClause;
import com.sl.au.entity.ExdeBeforeContractWGDetail;
import com.sl.au.entity.User;
import com.sl.au.repository.ExdeBeforeContractDetailPartsRepository;
import com.sl.au.repository.ExdeBeforeContractDetailsRepository;
import com.sl.au.repository.ExdeBeforeContractHQDetailRepository;
import com.sl.au.repository.ExdeBeforeContractNoticesRepository;
import com.sl.au.repository.ExdeBeforeContractRepository;
import com.sl.au.repository.ExdeBeforeContractSpecialClauseRepository;
import com.sl.au.repository.ExdeBeforeContractWGDetailRepository;

/***
 * 
 * @author chuck
 * 20170221 签订前要点审批service
 */
public interface ExdeBeforeContractService extends BaseService{
	
	ExdeBeforeContractRepository getExdeBeforeContractRepository();
	
	ExdeBeforeContractDetailsRepository getExdeBeforeContractDetailsRepository();
	
	ExdeBeforeContractDetailPartsRepository getExdeBeforeContractDetailPartsRespository();
	
	ExdeBeforeContractNoticesRepository getExdeBeforeContractNoticesRepository();
	
	ExdeBeforeContractSpecialClauseRepository getExdeBeforeContractSpecialClauseRepository();
	
	ExdeBeforeContractWGDetailRepository getExdeBeforeContractWGDetailRepository();
	
	ExdeBeforeContractHQDetailRepository getExdeBeforeContractHQDetailRepository();
	
	/***
	 * 通过用户获取负责人
	 * @param superior
	 * @return
	 */
	List<User> getAllSuperiorMenBySuperior(String superior);

	
	/***
	 * 通过用户ID查询待办会签列表
	 * @param UserId
	 * @return
	 */
	List<EXDEViExdeBeforeContractWithSign> getEXDEViExdeBeforeContractWithSignByUserId(String UserId);
	
	/**
	 * 汇总标的物指标价格到主表中
	 * @param detailId
	 * 返回主表ID
	 */
	String sumExdeBeforeContractDetailsPrices(String detailId);
	
	/**
	 * 汇总标的物合同总价
	 * @param bContractId
	 */
	List<Float> sumExdeBeforeContractDetailsPricesZJ(String bContractId);
	
	/***
	 * 初始化标的物子表信息
	 * @param detailId
	 */
	void initDetailsDetailsInfo(ExdeBeforeContractDetails exdeBeforeContractDetails);
	
	/***
	 * 会签是否完成状态控制-需要会签时调用
	 * @param beforeId
	 */
	void updateExdeBeforeContractCounterSignFinishState(String beforeId);
	
	/***
	 * 通过会签子表状态改变会签主表状态
	 * @param beforeId
	 */
	void updateExdeBeforeContractCounterSignState(String beforeId);
	
	/***
	 * 获取所有人员信息
	 * @return
	 */
	List<User> getAllUserList(int start,int size,String key);
	
	long getAllUserCount(String key);
	
	/**
	 * 配置客户审批界面
	 */
	List<User> getUserList(int start,int size,String key);
	long getUserCount(String key);
	
	/***
	 * 提交会签
	 * @param taskId
	 * @param userId
	 * @param auditMemo
	 */
	String submitExdeBeforeContractCounterSign(String taskId,String userId,String auditMemo);
	
	/***
	 * 获取登陆人待会签List
	 * @param start
	 * @param length
	 * @param userId
	 * @return
	 */
	List<ExdeBeforeContractCounterSign> getExdeBeforeContractCounterSignListByUserId(int start,int length,String userId);
	
	/**
	 * 获取签订前会签列表
	 */
	List<ExdeBeforeContractCounterSign> getBeforeContractsHQ(int start,int length,String beforeId);
	/**
	 * 获取签订前会签列表数据总数
	 */
	long getBeforeContractHQCount(String beforeId);
	/***
	 * 获取签订前审批列表
	 * @param start
	 * @param length
	 * @param condition
	 * @return
	 */
	List<ExdeBeforeContract> getBeforeContracts(int start,int length,Map<String, String> condition);
	
	
	/***
	 * 获取签订前审批数据总数
	 * @param condition
	 * @return
	 */
	long getBeforeContractCount(Map<String, String> condition);
	
	/***
	 * 根据ID查询签订前要点审批主表信息
	 * @param id
	 * @return
	 */
	ExdeBeforeContract getBeforeContract(String id);
	
	/***
	 * 通过签订前ID删除相关所有信息
	 * @param id
	 */
	void deleteContractById(String id);
	
	/***
	 * 通过签订前ID查询合同签订前审批产品子表
	 * @param start
	 * @param length
	 * @param id
	 * @return
	 */
	List<ExdeBeforeContractDetails> getExdeBeforeContractDetailsByBeforeId(int start,int length,String id);
	
	/***
	 * 通过签订前ID查询合同签订前审批产品子表Count
	 * @param id
	 * @return
	 */
	long getExdeBeforeContractDetailsCountByBeforeId(String id);
	
	/***
	 * 通过beforeDetailId查询合同签订前审批合同合同标的物子表的子表
	 * @param start
	 * @param length
	 * @param id
	 * @return
	 */
	List<ExdeBeforeContractDetailParts> getExdeBeforeContractDetailPartsByDetailId(int start,int length,String beforeDetailId);
	
	/***
	 * 通过beforeDetailId查询合同签订前审批合同合同标的物子表的子表数量
	 * @param beforeDetailId
	 * @return
	 */
	long getExdeBeforeContractDetailPartsCountByDetailId(String beforeDetailId);
	
	/***
	 * 通过beforeDetailId查询合同签订前审批其它注意条款子表
	 * @param start
	 * @param length
	 * @param beforeId
	 * @return
	 */
	List<ExdeBeforeContractNotices> getExdeBeforeContractNoticesByBeforeId(int start,int length,String beforeId);
	
	/***
	 * 通过beforeDetailId查询合同签订前审批其它注意条款子表数量
	 * @param beforeId
	 * @return
	 */
	long getExdeBeforeContractNoticesCountByBeforeId(String beforeId);
	
	/***
	 * 通过beforeDetailId查询合同签订前审批合同特殊条款子表
	 * @param start
	 * @param length
	 * @param beforeId
	 * @return
	 */
	List<ExdeBeforeContractSpecialClause> getExdeBeforeContractSpecialClauseByBeforeId(int start,int length,String beforeId);
	
	/***
	 * 通过beforeDetailId查询合同签订前审批合同特殊条款子表数量
	 * @param beforeId
	 * @return
	 */
	long getExdeBeforeContractSpecialClauseCountByBeforeId(String beforeId);
	
	/***
	 * 通过beforeDetailId查询合同签订前审批外购件独家指定子表
	 * @param start
	 * @param length
	 * @param beforeId
	 * @return
	 */
	List<ExdeBeforeContractWGDetail> getExdeBeforeContractWGDetailByBeforeId(int start,int length,String beforeId);
	
	/***
	 * 通过beforeDetailId查询合同签订前审批外购件独家指定子表数量
	 * @param beforeId
	 * @return
	 */
	long getExdeBeforeContractWGDetailCountByBeforeId(String beforeId);
	
	/***
	 * 初始化合同特殊条款、外购件独家制定
	 * @param id
	 */
	void initBaseDetailsInfo(String id,String superior);
	
	/***
	 * 批量删除合同签订前审批产品子表及对应指标
	 * @param ids
	 * 返回主表ID
	 */
	String deleteExdeBeforeContractDetails(String ids);
	
	/***
	 * 批量删除合同签订前审批其它注意条款子表
	 * @param ids
	 */
	void deleteExdeBeforeContractNotices(String ids);
	
	/***
	 * 批量删除合同签订前审批合同特殊条款子表
	 * @param ids
	 */
	void deleteExdeBeforeContractSpecialClause(String ids);
	
	/***
	 * 批量删除合同签订前审批外购件独家指定子表
	 * @param ids
	 */
	void deleteExdeBeforeContractWGDetail(String ids);
	
	/***
	 * 批量删除合同签订前审批合同合同标的物子表的子表
	 * @param ids
	 */
	String deleteExdeBeforeContractDetailParts(String ids);
	
	/***
	 * 批量删除会签审批人子表
	 * @param ids
	 */
	void deleteExdeBeforeContractCounterSigns(String ids);
	
	/***
	 * 流程实例数据保持到主表中
	 * @param beforeId
	 * @param pInst
	 */
	void saveProcessStart(String beforeId,ProcessInstance pInst);

	void saveExdeBeforeContractSpecialClause(ExdeBeforeContractSpecialClause exdeBeforeContractSpecialClause,
			List<ExdeBeforeContractSpecialClause> list, boolean isInit);

	void saveExdeBeforeContractNotices(ExdeBeforeContractNotices exdeBeforeContractNotices,
			List<ExdeBeforeContractNotices> contracts, boolean isInit);

	void saveExdeBeforeContractDetailParts(ExdeBeforeContractDetailParts exdeBeforeContractDetailParts,
			List<ExdeBeforeContractDetailParts> contracts, boolean isInit);

	void saveExdeBeforeContractWGDetail(ExdeBeforeContractWGDetail exdeBeforeContractWGDetail,
			List<ExdeBeforeContractWGDetail> contracts, boolean isInit);
}
